package com.huitone.gddw.service.impl.analysis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//import com.huitone.gddw.controller.QuarySmParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huitone.gddw.dao.analysis.ISettlementRepDao;
import com.huitone.gddw.service.analysis.ISettlementRepService;
import com.huitone.gddw.service.dto.analysis.SettlementRepACDTO;
import com.huitone.gddw.service.dto.analysis.SettlementRepDTO;
import com.huitone.gddw.service.system.IRoleService;
import com.huitone.gddw.utils.SysLoginUtil;

/**
 * 结算报表 接口实现类
 *
 * @author chengsiyyue
 */
@Service
public class SettlementRepService implements ISettlementRepService {

    @Autowired
    private ISettlementRepDao settlementRepDao;

    @Autowired
    private IRoleService roleService;

    @Override
    public List<SettlementRepDTO> find(Map<String, Object> map) {
//		map.put("isUnit",roleService.isRootAcsFlag(SysLoginUtil.getLoginUserId())?"1":"0");
        map.put("userId", SysLoginUtil.getLoginUserId());
        return settlementRepDao.find(map);
    }

    @Override
    public SettlementRepACDTO findCount(Map<String, Object> map) {
        map.put("isUnit", roleService.isRootAcsFlag(SysLoginUtil.getLoginUserId()) ? "1" : "0");//0：只能查询本单位数据
        map.put("userId", SysLoginUtil.getLoginUserId());
        SettlementRepACDTO settlementRepACDTO = new SettlementRepACDTO();
        settlementRepACDTO = settlementRepDao.findCount(map);
        if (settlementRepACDTO != null) settlementRepACDTO.setRecordList(this.find(map));
        return settlementRepACDTO;
    }

//    @Override
//    public SettlementRepACDTO queryChannel(QuarySmParam param) {
//        HashMap<String, Object> map = new HashMap<>();
//        map.put("startDate",param.getStartDate());
//        map.put("endDate",param.getEndDate());
//        map.put("dateFormat",param.getDateFormat());
//        map.put("isUnit",1);
//        SettlementRepACDTO dtc = settlementRepDao.findCount(map);
//        dtc.setRecordList( (settlementRepDao.find(map)));
//        return dtc;
//    }
}
